package cn.nange.cmfz.service.impl;

import cn.nange.cmfz.dao.BannerDao;
import cn.nange.cmfz.entity.Banner;
import cn.nange.cmfz.service.BannerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BannerServiceImpl implements BannerService {

    @Autowired
    private BannerDao bannerDao;
    @Override
    public void add(Banner b) {
bannerDao.insert(b);
    }

    @Override
    public void update(Banner b) {
bannerDao.update(b);
    }

    @Override
    public void delete(Integer id) {
bannerDao.delete(id);
    }

    @Override
    public Banner showOne(Integer id) {
        return bannerDao.selectOne(id);
    }

    @Override
    public PageInfo<Banner> showAll(int page, int rows) {
        PageHelper.startPage(page, rows);
        PageInfo<Banner> pageInfo = new PageInfo<>(bannerDao.selectAll());
        return pageInfo;
    }

}
